<template>
    <el-select v-model="selectValue"
               @change="changeVal"
               clearable
               :disabled="disabled"
               :placeholder="placeholder"
               style="width: 100%"
    >
        <el-option
                v-for="item in this.$store.state.system.sysDict"
                v-if="item.codeName == codeName"
                :key="item.value"
                :label="item.codeText"
                :value="item.codeValue">
        </el-option>
    </el-select>
</template>

<script>
export default {
    name: "DictSelect",
    props:{
        codeName:{type:String},
        placeholder:{type: String,default:"请选择"},
        dictValue:{},
        disabled:{type:Boolean,default: false}
    },
    data(){
        return {
            selectValue: this.dictValue
        }
    },
    methods:{
        changeVal(val){
            this.$emit("update:dictValue",val);
        }
    },
    watch:{
        dictValue(newVal,oldVal){
            this.selectValue = newVal
        }
    },
}
</script>
